<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>try do</title>
</head>
<script>
	var n=prompt("请输入金字塔的层数");
	n=Number(n);//输入的层数
	
	var i=1;//当前层数
	while(i<=n){
		var j=1 , k=1;//点的个数
		while(n>=k+i){
			document.write("&nbsp;");
			k++;
		}
		while(j<=2*i-1){
		document.write("*");
			j++;
		}
		document.write("<br>");
		i++;
		
	}
	</script>

<body>
</body>
</html>
